home *** CD-ROM | disk | FTP | other *** search
/ Tech Win 1996 January / CD [TECH_A].bin / tech_a / vb4wm / vb4-4.cab / calc.frm (.txt) < prev    next >
Encoding:
Visual Basic Form  |  1995-10-25  |  11.4 KB  |  435 lines

  1. VERSION 4.00
  2. Begin VB.Form Calculator 
  3.    BorderStyle     =   1  '
  4.    Caption         =   "
  5.    ClientHeight    =   2970
  6.    ClientLeft      =   2580
  7.    ClientTop       =   1485
  8.    ClientWidth     =   3270
  9.    ClipControls    =   0   'False
  10.    BeginProperty Font 
  11. name = "
  12.       charset         =   1
  13.       weight          =   700
  14.       size            =   9.75
  15.       underline       =   0   'False
  16.       italic          =   0   'False
  17.       strikethrough   =   0   'False
  18. Bold = 0
  19.    EndProperty
  20.    Height          =   3375
  21.    Icon            =   "CALC.frx":0000
  22.    Left            =   2520
  23.    LinkMode        =   1  '
  24.    LinkTopic       =   "Form1"
  25.    MaxButton       =   0   'False
  26.    ScaleHeight     =   2970
  27.    ScaleWidth      =   3270
  28.    Top             =   1140
  29.    Width           =   3390
  30.    Begin VB.CommandButton Number 
  31.       Caption         =   "7"
  32.       Height          =   480
  33.       Index           =   7
  34.       Left            =   120
  35.       TabIndex        =   7
  36.       Top             =   600
  37.       Width           =   480
  38. BeginProperty Font
  39. name = "
  40. size = 9
  41. Bold = 0
  42. EndProperty
  43.    End
  44.    Begin VB.CommandButton Number 
  45.       Caption         =   "8"
  46.       Height          =   480
  47.       Index           =   8
  48.       Left            =   720
  49.       TabIndex        =   8
  50.       Top             =   600
  51.       Width           =   480
  52. BeginProperty Font
  53. name = "
  54. size = 9
  55. Bold = 0
  56. EndProperty
  57.    End
  58.    Begin VB.CommandButton Number 
  59.       Caption         =   "9"
  60.       Height          =   480
  61.       Index           =   9
  62.       Left            =   1320
  63.       TabIndex        =   9
  64.       Top             =   600
  65.       Width           =   480
  66. BeginProperty Font
  67. name = "
  68. size = 9
  69. Bold = 0
  70. EndProperty
  71.    End
  72.    Begin VB.CommandButton Cancel 
  73.       Caption         =   "C"
  74.       Height          =   480
  75.       Left            =   2040
  76.       TabIndex        =   10
  77.       Top             =   600
  78.       Width           =   480
  79. BeginProperty Font
  80. name = "
  81. size = 9
  82. Bold = 0
  83. EndProperty
  84.    End
  85.    Begin VB.CommandButton CancelEntry 
  86.       Caption         =   "CE"
  87.       Height          =   480
  88.       Left            =   2640
  89.       TabIndex        =   11
  90.       Top             =   600
  91.       Width           =   480
  92. BeginProperty Font
  93. name = "
  94. size = 9
  95. Bold = 0
  96. EndProperty
  97.    End
  98.    Begin VB.CommandButton Number 
  99.       Caption         =   "4"
  100.       Height          =   480
  101.       Index           =   4
  102.       Left            =   120
  103.       TabIndex        =   4
  104.       Top             =   1200
  105.       Width           =   480
  106. BeginProperty Font
  107. name = "
  108. size = 9
  109. Bold = 0
  110. EndProperty
  111.    End
  112.    Begin VB.CommandButton Number 
  113.       Caption         =   "5"
  114.       Height          =   480
  115.       Index           =   5
  116.       Left            =   720
  117.       TabIndex        =   5
  118.       Top             =   1200
  119.       Width           =   480
  120. BeginProperty Font
  121. name = "
  122. size = 9
  123. Bold = 0
  124. EndProperty
  125.    End
  126.    Begin VB.CommandButton Number 
  127.       Caption         =   "6"
  128.       Height          =   480
  129.       Index           =   6
  130.       Left            =   1320
  131.       TabIndex        =   6
  132.       Top             =   1200
  133.       Width           =   480
  134. BeginProperty Font
  135. name = "
  136. size = 9
  137. Bold = 0
  138. EndProperty
  139.    End
  140.    Begin VB.CommandButton Operator 
  141.       Caption         =   "+"
  142.       Height          =   480
  143.       Index           =   1
  144.       Left            =   2040
  145.       TabIndex        =   12
  146.       Top             =   1200
  147.       Width           =   480
  148. BeginProperty Font
  149. name = "
  150. size = 9
  151. Bold = 0
  152. EndProperty
  153.    End
  154.    Begin VB.CommandButton Operator 
  155.       Caption         =   "-"
  156.       Height          =   480
  157.       Index           =   3
  158.       Left            =   2640
  159.       TabIndex        =   13
  160.       Top             =   1200
  161.       Width           =   480
  162. BeginProperty Font
  163. name = "
  164. size = 9
  165. Bold = 0
  166. EndProperty
  167.    End
  168.    Begin VB.CommandButton Number 
  169.       Caption         =   "1"
  170.       Height          =   480
  171.       Index           =   1
  172.       Left            =   120
  173.       TabIndex        =   1
  174.       Top             =   1800
  175.       Width           =   480
  176. BeginProperty Font
  177. name = "
  178. size = 9
  179. Bold = 0
  180. EndProperty
  181.    End
  182.    Begin VB.CommandButton Number 
  183.       Caption         =   "2"
  184.       Height          =   480
  185.       Index           =   2
  186.       Left            =   720
  187.       TabIndex        =   2
  188.       Top             =   1800
  189.       Width           =   480
  190. BeginProperty Font
  191. name = "
  192. size = 9
  193. Bold = 0
  194. EndProperty
  195.    End
  196.    Begin VB.CommandButton Number 
  197.       Caption         =   "3"
  198.       Height          =   480
  199.       Index           =   3
  200.       Left            =   1320
  201.       TabIndex        =   3
  202.       Top             =   1800
  203.       Width           =   480
  204. BeginProperty Font
  205. name = "
  206. size = 9
  207. Bold = 0
  208. EndProperty
  209.    End
  210.    Begin VB.CommandButton Operator 
  211.       Caption         =   "X"
  212.       Height          =   480
  213.       Index           =   2
  214.       Left            =   2040
  215.       TabIndex        =   14
  216.       Top             =   1800
  217.       Width           =   480
  218. BeginProperty Font
  219. name = "
  220. size = 9
  221. Bold = 0
  222. EndProperty
  223.    End
  224.    Begin VB.CommandButton Operator 
  225.       Caption         =   "/"
  226.       Height          =   480
  227.       Index           =   0
  228.       Left            =   2640
  229.       TabIndex        =   15
  230.       Top             =   1800
  231.       Width           =   480
  232. BeginProperty Font
  233. name = "
  234. size = 9
  235. Bold = 0
  236. EndProperty
  237.    End
  238.    Begin VB.CommandButton Number 
  239.       Caption         =   "0"
  240.       Height          =   480
  241.       Index           =   0
  242.       Left            =   120
  243.       TabIndex        =   0
  244.       Top             =   2400
  245.       Width           =   1080
  246. BeginProperty Font
  247. name = "
  248. size = 9
  249. Bold = 0
  250. EndProperty
  251.    End
  252.    Begin VB.CommandButton Decimal 
  253.       Caption         =   "."
  254.       Height          =   480
  255.       Left            =   1320
  256.       TabIndex        =   18
  257.       Top             =   2400
  258.       Width           =   480
  259. BeginProperty Font
  260. name = "
  261. size = 9
  262. Bold = 0
  263. EndProperty
  264.    End
  265.    Begin VB.CommandButton Operator 
  266.       Caption         =   "="
  267.       Height          =   480
  268.       Index           =   4
  269.       Left            =   2040
  270.       TabIndex        =   16
  271.       Top             =   2400
  272.       Width           =   480
  273. BeginProperty Font
  274. name = "
  275. size = 9
  276. Bold = 0
  277. EndProperty
  278.    End
  279.    Begin VB.CommandButton Percent 
  280.       Caption         =   "%"
  281.       Height          =   480
  282.       Left            =   2640
  283.       TabIndex        =   17
  284.       Top             =   2400
  285.       Width           =   480
  286. BeginProperty Font
  287. name = "
  288. size = 9
  289. Bold = 0
  290. EndProperty
  291.    End
  292.    Begin VB.Label Readout 
  293.       Alignment       =   1  '
  294.       BackColor       =   &H0000FFFF&
  295.       BorderStyle     =   1  '
  296.       Caption         =   "0."
  297.       BeginProperty Font 
  298. name = "
  299.          charset         =   1
  300.          weight          =   700
  301.          size            =   12
  302.          underline       =   0   'False
  303.          italic          =   0   'False
  304.          strikethrough   =   0   'False
  305. Bold = 0
  306.       EndProperty
  307.       ForeColor       =   &H00000000&
  308.       Height          =   375
  309.       Left            =   120
  310.       TabIndex        =   19
  311.       Top             =   105
  312.       Width           =   3000
  313.    End
  314. Attribute VB_Name = "Calculator"
  315. Attribute VB_Creatable = False
  316. Attribute VB_Exposed = False
  317. Option Explicit
  318. Dim Op1, Op2                ' 
  319. Dim DecimalFlag As Integer  ' 
  320. Dim NumOps As Integer       ' 
  321. Dim LastInput               ' 
  322. Dim OpFlag                  ' 
  323. Dim TempReadout
  324. ' [C] 
  325.  Click 
  326. Private Sub Cancel_Click()
  327.     ReadOut = Format(0, "0.")
  328.     Op1 = 0
  329.     Op2 = 0
  330.     Form_Load
  331. End Sub
  332. ' [CE] 
  333.  Click 
  334. Private Sub CancelEntry_Click()
  335.     ReadOut = Format(0, "0.")
  336.     DecimalFlag = False
  337.     LastInput = "CE"
  338. End Sub
  339. ' [.] 
  340.  Click 
  341.  "0." 
  342. Private Sub Decimal_Click()
  343.     If LastInput = "NEG" Then
  344.         ReadOut = Format(0, "-0.")
  345.     ElseIf LastInput <> "NUMS" Then
  346.         ReadOut = Format(0, "0.")
  347.     End If
  348.     DecimalFlag = True
  349.     LastInput = "NUMS"
  350. End Sub
  351. Private Sub Form_Load()
  352.     DecimalFlag = False
  353.     NumOps = 0
  354.     LastInput = "NONE"
  355.     OpFlag = " "
  356.     ReadOut = Format(0, "0.")
  357.     Decimal.Caption = Format(0, ".")
  358. End Sub
  359.  (0-9) 
  360.  Click 
  361. Private Sub Number_Click(Index As Integer)
  362.     If LastInput <> "NUMS" Then
  363.         ReadOut = Format(0, ".")
  364.         DecimalFlag = False
  365.     End If
  366.     If DecimalFlag Then
  367.         ReadOut = ReadOut + Number(Index).Caption
  368.     Else
  369.         ReadOut = Left(ReadOut, InStr(ReadOut, Format(0, ".")) - 1) + Number(Index).Caption + Format(0, ".")
  370.     End If
  371.     If LastInput = "NEG" Then ReadOut = "-" & ReadOut
  372.     LastInput = "NUMS"
  373. End Sub
  374.  (+, -, x, /, =) 
  375.  Click 
  376. ANumOps 
  377. AOp1 
  378. AOp1 
  379. ' Op1 
  380. Private Sub Operator_Click(Index As Integer)
  381.     TempReadout = ReadOut
  382.     If LastInput = "NUMS" Then
  383.         NumOps = NumOps + 1
  384.     End If
  385.     Select Case NumOps
  386.         Case 0
  387.         If Operator(Index).Caption = "-" And LastInput <> "NEG" Then
  388.             ReadOut = "-" & ReadOut
  389.             LastInput = "NEG"
  390.         End If
  391.         Case 1
  392.         Op1 = ReadOut
  393.         If Operator(Index).Caption = "-" And LastInput <> "NUMS" And OpFlag <> "=" Then
  394.             ReadOut = "-"
  395.             LastInput = "NEG"
  396.         End If
  397.         Case 2
  398.         Op2 = TempReadout
  399.         Select Case OpFlag
  400.             Case "+"
  401.                 Op1 = CDbl(Op1) + CDbl(Op2)
  402.             Case "-"
  403.                 Op1 = CDbl(Op1) - CDbl(Op2)
  404.             Case "X"
  405.                 Op1 = CDbl(Op1) * CDbl(Op2)
  406.             Case "/"
  407.                 If Op2 = 0 Then
  408.                    MsgBox "
  409. B", 48, "
  410.                 Else
  411.                    Op1 = CDbl(Op1) / CDbl(Op2)
  412.                 End If
  413.             Case "="
  414.                 Op1 = CDbl(Op2)
  415.             Case "%"
  416.                 Op1 = CDbl(Op1) * CDbl(Op2)
  417.             End Select
  418.         ReadOut = Op1
  419.         NumOps = 1
  420.     End Select
  421.     If LastInput <> "NEG" Then
  422.         LastInput = "OPS"
  423.         OpFlag = Operator(Index).Caption
  424.     End If
  425. End Sub
  426. ' [%] 
  427.  Click 
  428. Private Sub Percent_Click()
  429.     ReadOut = ReadOut / 100
  430.     LastInput = "Ops"
  431.     OpFlag = "%"
  432.     NumOps = NumOps + 1
  433.     DecimalFlag = True
  434. End Sub
  435.